<?php


namespace app\common\cachemodel;

use app\common\model\BaseCache;
use think\Log;
use XznsTools\cache\CacheManage;

class AstroChangeText extends BaseCache
{
    protected $table = 'wechat_backup_07_18_14_43_00.app_astro_change_text';
    protected $cacheModel = 'astro.change_text';

    /**
     * 获取天象变动词条
     * @param $where
     * @return array|bool|mixed|string
     * @throws \Exception
     */
    public function getChangeText($where)
    {
        $id = implode('_', $where);

        return CacheManage::getInstance()->setCacheConfig($this->cacheModel, $id)
            ->getDataAndSet(function () use ($where)
            {
                try
                {
                    $where['status'] = 1;
                    $changeText = $this->where($where)->value('text');
                }
                catch (\Exception $e)
                {
                    $changeText = '';
                    Log::write("天象变动词条获取异常app\common\cachemodel\AstroChangeText->getChangeText()，行{$e->getLine()},消息：{$e->getMessage()}", 'error', true);
                }

                return $changeText ?? '';
            });
    }
}
